begintalkscript;
variables;

// Smith, Blacksmith

begintalknode 1;
state = -1;
personality = 0;
nextstate = 1;
question = "Smith";
text1 = "A fairly strong looking man is managing the blacksmithy here, and you note the quality of his equipment is impressive, despite the presence of a few bad blades here and there.";
text2 = "He carefully pays attention to the details of a suit of armor he is currently making, and he is displeased by the distraction.  He brightens when, as it seems, he recalls that you may be a paying customer.";
text3 = "He looks to you questioningly.  _I haven't seen you around here before.  You must be another of those 'travelers' or 'adventurers' or 'explorers' or whatever you want to call yourselves._";
text4 = "_Anyway, my name is Smith.  If you have need of anything to assist you in the stabbing of various fiends, I have what you're looking for._  He motions to his array of weapons and armor.";
text5 = "He looks up from his work to see you enter.  _Yes?  Is there something you need?_";
action = INTRO;

begintalknode 2;
state = 1;
nextstate = -1;
question = "I'm looking for some equipment.";
text1 = "You conclude your shopping.";
code = 
	begin_shop_mode("Smith's Smithy","Smith has a variety of tools to use for the stabbing of fiends.  Their quality ranges from half-decent to fairly good.",0,3,4);
break;
action = END_TALK;

begintalknode 3;
state = 1;
nextstate = -1;
question = "Is there much profit to be made in the smithing career?";
text1 = "He nods.  _It mostly depends on location.  Since we're surrounded by baddies and since adventurers are pouring in, I make plenty._";

begintalknode 4;
state = 1;
nextstate = -1;
condition = (get_flag(0,9) == 0);
question = "Did you change your name to Smith so it matched your job?";
text1 = "He stops and suddenly realization hits him.  _Woah,_ he says with a shocked look on his face.  _I never made that connection._  He looks down.";
text2 = "_I guess that explains why people always chuckled when I told them my name..._";
code = 
	set_flag(0,9,1);
break;

// Balu, Magic User Extraordinaire

begintalknode 5;
state = -1;
personality = 1;
nextstate = 2;
question = "Balu";
text1 = "A wizened old man hurries about his study, or lab, or whatever one might call this particular assortment of junk he waddles through.  His beard and hair are greyed from age, and there is a certain sharpness in his eyes.";
text2 = "Nevertheless, he still seems befuddled in his attempts to find the right tool.  Uncomfortably he sorts through the piles to find something while holding a test tube in the air.";
text3 = "When you approach, he barely looks up, but it is clear he has noticed your presence.  _Wait a moment and I'll attend to your needs,_ he says in an overly loud voice, as if he can't quite hear himself.";
text4 = "_Let me know if you see an eyedropper around here.  I know I had it somewhere._ He drones off into mumblings and cursings.  _Ah!_  He raises up with an eyedropper in his hand.  _Now, what did you need?_";
text5 = "The old man is still conducting experiments and walking to and fro to attend to yet other experiments.  _Is there something you need?_ he booms, without looking up.";
action = INTRO;

begintalknode 6;
state = 2;
nextstate = 99;
condition = (get_flag(0,11) == 0);
question = "What are you making?";
text1 = "He drops a bit of liquid into the brown substance in his hand.  After carefully observing the reaction, he downs it all in one gulp.  _Chocolate milk,_ he says, grinning.";
text2 = "_I was thirsty, so..._ he trails off, then thinks for a moment.  _Say, you wouldn't be willing to help me out a bit, would you?  I'm looking for some ingredients..._";
text3 = "_I'm trying to create this new potion, and it's really useful.  If you could find me what I need for it, I'd give it to you._  He sees your worried looks and quickly says, _Not to worry!  I know exactly how to make it, so its no risk to drink it._";
text4 = "_Well, eheh... I know exactly how to make it except for one part.  There's this book... I know it's in here somewhere, but I can't find the darned thing!  Can you find it for me?  It has some information I need._";
code = 
	set_flag(0,11,1);
	toggle_quest(0,1);
break;

begintalknode 99;
state = 99;
nextstate = -1;
question = "I'll let you know if I see it.";
text1 = "_Thanks.  Please hurry, if you can._";
action = END_TALK;

begintalknode 7;
state = 2;
nextstate = -1;
question = "Can you teach me any spells or alchemy?";
text1 = "You finish your training.";
code = 
	begin_shop_mode("Balu's Magic and Alchemy","Balu prides himself on his mastery of both mage and priest spells.  He is more than willing to teach you if you are willing to pay him.",1,4,-1);
break;
action = END_TALK;

begintalknode 8;
state = 2;
nextstate = 3;
question = "I think I found the book you needed.";
condition = (has_item(445) == 1);
text1 = "He is pleasantly surprised.  _Excellent!  I was looking for that.  Thank you much._  He looks through it for a moment and then throws it across the room, disgusted.  _Just as I thought,_ he grumbles.  _I need a lot of rare ingredients._";
text2 = "_Well, if you're willing, I'll tell you what I need and hopefully you can find them.  Alright?  Are you ready to hear what I need?_  He pauses.  _I need asptongue, spider's glands, and caterpillars._";
text3 = "_Did you get all that?_";
code = 
	has_item_of_class(1,1);
	set_flag(0,10,1);
	toggle_quest(0,0);
	award_party_xp(50,2);
	toggle_quest(1,1);
break;

begintalknode 9;
state = 3;
nextstate = -1;
question = "Um... caterpillars?";
text1 = "_Yes, yes, caterpillars!  They are absolutely essential!  The key ingredient!_  He waves his arms around to signify their importance.  _Understand?_  You nod.";
text2 = "_Good!  Now go on and find those ingredients.  I can't wait to make my new potion.  It'll make me famous!_  He turns around to find that you are still there.  _Well, go on! And don't forget -- caterpillars!_";
action = END_TALK;

begintalknode 10;	// Node for having found caterpillars.
state = 2;
nextstate = -1;
question = "I found some caterpillars.";
condition = ((has_special_item(0) == 1) && (get_flag(0,10) == 1));
text1 = "_Good!  I'll take those._  You hand him the caterpillars.";
code = 
	take_special_item(0);
	inc_flag(0,25,1);
break;

begintalknode 46;	// Node for giving the spider glands.
state = 2;
nextstate = -1;
question = "I found some spider's glands.";
condition = ((has_special_item(1) == 1) && (get_flag(0,10) == 1));
text1 = "_Good!  I'll take those._  You hand him the spider glands.";
code = 
	take_special_item(1);
	inc_flag(0,25,1);
break;

begintalknode 47;	// Node for giving the asptongue.
state = 2;
nextstate = -1;
question = "I found an asptongue.";
condition = ((has_special_item(2) == 1) && (get_flag(0,10) == 1));
text1 = "_Good!  I'll take that._  You hand him the asptongue.";
code = 
	take_special_item(2);
	inc_flag(0,25,1);
break;

begintalknode 48;
state = 2;
nextstate = -1;
question = "I think you have all the ingredients you need now.";
condition = (get_flag(0,25) == 3);
text1 = "_Why, yes I do!  Thanks for reminding me.  I'll have your potion in a jiffy._  He rushes over to his alchemical equipment and inserts the three ingredients in a bottle.";
text2 = "After mixing them and adding something else, he hands you the fizzing, bubbling potion, smiles, and says, _Enjoy._";
code = 
	set_flag(0,25,4);
	reward_give(450);
	toggle_quest(1,0);
	award_party_xp(100,5);
break;


begintalknode 11;
state = 2;
nextstate = -1;
question = "I was just wandering around.  Didn't mean to bother you.";
text1 = "_Quite all right,_ he says, and resumes his work.";
action = END_TALK;

begintalknode 12;	// Parry, Producer of Paraphernalia
state = -1;
personality = 2;
nextstate = 10;
question = "Parry";
text1 = "This short man grins at the prospect of making some cash in the next few minutes.  _Hello, my good friends,_ he says.  _My name is Parry.  Might I interest you in some useful oddities?_";
text2 = "_Some nice boots, perhaps?  Or these lockpicks?  Maybe a toothbrush?  Parry's Paraphernalia Emporium has it all, from shoes to slicers, from lockpicks to toothpicks.  I can even identify your items._";
text3 = "_Feel free to browse, my friend, and let me know if you wish to make a purchase._";
text5 = "Parry is still here, waiting eagerly for more customers.";
action = INTRO;

begintalknode 13;
state = 10;
nextstate = -1;
question = "I'd like to make some purchases.";
text1 = "You finish your shopping.";
code = 
	begin_shop_mode("Parry's Paphernalia","Parry has a wide variety of trinkets here for sale.  He makes small suggestions here and there, recommending not to leave empty-handed.",2,3,3);
break;
action = END_TALK;

begintalknode 49;
state = 10;
nextstate = 40;
question = "I'd like to have some items identified.";
text1 = "Parry looks over your possesions.  _Hmm... mm-hm... okay.  10 gold per item._";
action = ID 10;

begintalknode 14;
state = 10;
nextstate = -1;
condition = (get_flag(0,20) == 0);
question = "Do you know anything about the Cave of No Return?";
text1 = "Parry becomes uneasy.  _I'm afraid I don't, other than that you shouldn't go near there.  There's a reason for its name, mind you, so it's unlikely that you'll survive if you even do so much as approach it._";
code = 
	set_flag(0,20,1);
break;

begintalknode 15;
state = 10;
nextstate = 11;
question = "Do you carry any missiles?";
text1 = "_No, I don't, because there's a fine store around the corner, Bubba's projectiles, that does.  You can get there through the passage in the back.  This door, right here next to me._";

begintalknode 16;
state = 11;
nextstate = -1;
question = "Why are the two stores attached?";
text1 = "_Well, it saves on the rent, plus me and him don't have to compete when it comes to dealing in missile weapons._";

begintalknode 17;	// Bubba, projectile carver and fletcher
state = -1;
personality = 3;
nextstate = 12;
question = "Bubba";
text1 = "A lazy looking archer leans back in his chair, whittling away at a javelin rod.  He looks up, carves a few more shavings off, then says _Hullo.  What kin ah do fer yeh?_";
text5 = "Bubba is now working on an arrow.  _Need suh'im?_";
action = INTRO;

begintalknode 18;
state = 12;
nextstate = -1;
question = "Pardon?";
condition = (get_flag(0,12) == 0);
text1 = "_Shucks, 'ats jus' m' accent.  'Tracts more bi'ness 'at way, y'know?_  He looks at the table for a moment, then back up at you.  _Hello.  Sorry, I put on that 'Bubba' act because it gives something people to remember me by._";
text2 = "_Don't tell anyone, though.  I'd lose business._  He looks down to his carving.  _So what kin ah gits ya?_";
code = 
	set_flag(0,12,1);
break;

begintalknode 19;
state = 12;
nextstate = -1;
question = "I need some missiles.";
text1 = "You finish your shopping.";
code = 
	begin_shop_mode("Bubba's Projectiles","Bubba offers his quality projectile weapons to you for decent prices.  At least, that's how you interpreted 'I gots some real good weapuns an' fer such cheap prices, too!  Hoo doggy!'",3,3,4);
break;
action = END_TALK;

begintalknode 20;
state = 12;
nextstate = -1;
condition = (get_flag(0,21) == 0);
question = "Heard anything about the Cave of No Return?";
text1 = "_Nopers, nuttin' 't'all.  One dang'rous place, though, that there cave is._";
code = 
	set_flag(0,21,1);
break;

begintalknode 21;	// Liss, full-time mother doing taxes
state = -1;
personality = 3;
nextstate = -1;
question = "Liss";
text1 = "This woman looks very frustrated as she angrily fills out the papers on the table.  _Please don't bother me right now.  Taxes._";
action = END_TALK;

begintalknode 22;	// Little girl playing with a stick and some boots
state = -1;
personality = 4;
nextstate = 20;
question = "Child";
text1 = "This small girl is playing around with a stick, a rock, and some boots.  She seems to be pretending that the stick and the boots are battling.  _I got you now, you dirty old boot!_ she yells, as she hits the stick against the boot.";
text2 = "_Nuh-uh!_ she yells in a lower voice, and she steps on the stick with the boot.  _Ouchies!_ she yells.";
text5 = "The child is still playing around with the boots, a rock, and a stick.";
action = INTRO;

begintalknode 23;
state = 20;
nextstate = 21;
question = "Are you having fun?";
text1 = "_Yup!_ she says happily.  _Save me, save me!_ she says as she wiggles the rock.  _I'm trying!_ she says, waving the stick around.";

begintalknode 24;
state = 21;
nextstate = 22;
question = "Can I play?";
text1 = "_Okay!_ She pushes the boots over to you.  _You can be the mean ol' boots, and I'll be the heroic lovely stick princess warrior!_  She picks up the stick.  _Now they have to do battle!_ she yells.";

begintalknode 25;
state = 22;
nextstate = 23;
question = "I'm going to step on you, stick princess!";
text1 = "_No, I'M gonna bonk YOU on the head first!_ She whacks the boots with the stick.  _I'll save you, rocky!  Mr. Boots is going to pay!_";

begintalknode 26;
state = 23;
nextstate = 24;
question = "Kick the stick with the boots.";
text1 = "_Owee!_  She throws the stick in the air and barely catches it.  _I'm gonna use my SUPER MOVE!!  Eat this!_  She whacks the stick against the boots a whole bunch of times.";

begintalknode 27;
state = 24;
nextstate = -1;
question = "Oof!  You win!";
text1 = "_Yaaay!  Now me and rocky can go back to the castle and celebrate!!_  She continues on with her game without you.";
action = END_TALK;

begintalknode 28;
state = 23;
nextstate = -1;
question = "I changed my mind... I have to go.";
text1 = "_Aaaaww!_  She takes the boots from you and continues playing from where she left off.";
action = END_TALK;

begintalknode 29;
state = 22;
nextstate = 23;
question = "I'll never let you save Mr. Rock!";
text1 = "The little girl is annoyed.  _His name is ROCKY, not Mr. Rock.  Duh!_  She picks up the stick again.  _I'll save rocky!_";

begintalknode 30;
state = 22;
nextstate = -1;
question = "Time to die, stick princess!";
text1 = "Her mother looks over her shoulder and gives you a sharp glare.  _My mommy says we can't use that word,_ the girl explains.";

begintalknode 31;
state = 22;
nextstate = -1;
question = "Nevermind, I don't have time for this.";
text1 = "_Aaaaww!_  She takes the boots from you and continues playing from where she left off.";
action = END_TALK;

begintalknode 32;	// Mayor Dumed, mayor of Dapplen.
state = -1;
personality = 5;
nextstate = 30;
question = "Mayor Dumed";
text1 = "You enter the mayor's office, much to his displeasure.  His pen busily moving, he takes only a few seconds to scan each paper, another few to write on it, and then one more to push it out of the way as he moves on to the next paper.";
text2 = "He seems to be busy, but he still stops to talk with you.  _Hello.  You must be a newcomer.  I am Mayor Dumed._";
text5 = "Mayor Dumed is still here filling out papers.  _What can I do for you?_ he says, without looking up.";
action = INTRO;

begintalknode 33;
state = 30;
nextstate = -1;
question = "You are the mayor?  What do you do exactly?";
text1 = "_Basically, I run the town's political and economical affairs.  If we're in trouble, I have to come up with a solution._ He sighs.  _And, regretfully, I have to deal with any paperwork._";

begintalknode 34;
state = 30;
nextstate = 31;
condition = get_flag(0,14) == 0;
question = "I would like to ask you about the Cave of No Return.";
text1 = "He looks troubled.  _Ah, yes, that.  You see, there's this cave to the north of here, and its rumored to have a huge stash of loot inside.  Many adventurers have headed that way, and, naturally, did not return._";
text2 = "_The Cave is a plague on this town.  Nearly every day, another man passes through here, trying to get the loot of the Cave.  Few even make it all the way to it.  No doubt everyone you've talked to expects that you won't live long._";
text3 = "_I wish I could stop you, but if you are insistent on marching to your deaths, then I cannot prevent you.  The Cave is to the north, through the Giant's Forest at least.  There may be more obstacles, but all we have seen is the forest._";
text4 = "He sighs deeply.  _It was nice knowing you, my friend._";
code = 
	set_flag(0,14,1);
	toggle_quest(2,1);
break;

begintalknode 35;
state = 30;
nextstate = -1;
condition = get_flag(0,15) == 0;
question = "Heh.  Mayor Dumed.  That sounds kind of like Mayor Dumbhead!";
text1 = "He stares at you blankly.";
action = END_TALK;
code = 
	set_flag(0,15,1);
break;

begintalknode 36;
state = 31;
nextstate = 32;
question = "Don't worry.  I can manage myself.";
text1 = "_I wish I could believe you.  I have seen too many run to their deaths to think you could survive.  I wish you luck anyway.  Not that it will help._  He picks up his pen.  _Now, please leave.  I have to return to my paperwork._";
action = END_TALK;

begintalknode 37;	// Guard
state = -1;
personality = 6;
nextstate = -1;
question = "Guard";
text1 = "You make small talk with the guard, but the conversation gets boring quickly.  You soon bid him farewell.";
action = END_TALK;

begintalknode 38;	// Esther, Priest of the Great Fish
state = -1;
personality = 7;
nextstate = 33;
question = "Esther";
text1 = "A middle aged woman is seated here, seemingly deep in thought.  She wakens from her reverie when you enter.  After looking you over, she says, _Welcome, travelers.  I am Esther of the Great Fish.  If you have need of healing, I can provide it._";
text2 = "_Of course, you would have to give a donation first._";
text5 = "Esther is still here, waiting to offer her services to the wounded.";
action = INTRO;

begintalknode 39;
state = 33;
personality = 7;
nextstate = 34;
condition = get_flag(3,5) == 0;
question = "I'd like some healing.";
text1 = "She nods understandingly.  _It will cost you.  I offer my services for 100 gold, no less.  Are you willing?_";

begintalknode 40;
state = 34;
nextstate = -1;
question = "I am willing. (Pay 100 gold.)";
text1 = "She closes her eyes and begins to mumble sacred chantings.  Soon there is a flash of light, and you are restored.";
text3 = "_I guess you are all right after all._";
text5 = "_I am afraid that you don't have the money.  Please return when you do._";
code = 
	clear_strings();
	if (coins_amount() < 100)
		add_string(5);
	else	if (run_select_a_pc(1) == 0)
			add_string(3);
		else	{
			play_sound(24);
			add_string(1);
			restore_pc(get_selected_pc());
			change_coins(-100);	}
break;

begintalknode 41;
state = 33;
nextstate = 35;
question = "What's the Great Fish?";
text1 = "She smiles.  _I'm glad you asked.  The Great Fish is the One who created the world.  He was born in the and blah blah blah..._  She blathers on with endless religious history of the Great Fish.";

begintalknode 42;
state = 35;
nextstate = -1;
question = "Er... that's all I wanted to know, thanks.";
text1 = "She pauses, then shrugs.  _Oh well.  Let me know if you want to learn more._";
action = END_TALK;

begintalknode 43;
state = 35;
nextstate = -1;
question = "Sounds like a bunch of hogwash to me.";
text1 = "_Well, some of the less enlightened,_ she says angrily, _may not fully understand the truth of the Great Fish._ She turns away.";
action = END_TALK;
code = 
	set_flag(3,5,1);
break;

begintalknode 60;
state = 33;
nextstate = -1;
condition = get_flag(2,11) == 0;
question = "Know anything about the Cave of No Return?";
text1 = "She frowns.  _No, I'm afraid I don't know about that._";
code = 
	set_flag(2,11,1);
break;

begintalknode 44;	// Additional node for Smith.
state = 1;
personality = 0;
condition = (get_flag(0,18) == 0);
nextstate = -1;
question = "Do you know anything about the Cave of No Return?";
text1 = "Smith looks grim.  _You shouldn't go near that place, is all I know.  It's just not a good place to be._  He turns away and resumes his work.";
code = 
	set_flag(0,18,1);
break;

begintalknode 45;	// Additional node for Balu.
state = 2;
condition = (get_flag(0,19) == 0);
nextstate = -1;
question = "Do you happen to know anything about the Cave of No Return?";
text1 = "Balu frowns.  _Now don't you be going there.  It's not prudent.  That place is death itself, I swear!_  He refuses to say anything more on the subject.";
code = 
	set_flag(0,19,1);
break;

begintalknode 65;	// More nodes for Esther.
state = 34;
nextstate = -1;
question = "No thanks.";
text1 = "She shrugs and turns away, uninterested now that you decided against being profitable to her.";
action = END_TALK;

begintalknode 66;
state = 33;
nextstate = 55;
condition = get_flag(3,5) == 1;
question = "I'd like some healing.";
text1 = "She nods understandingly.  _It will cost you.  I offer my services for 150 gold, no less.  Are you willing?_";

begintalknode 67;
state = 55;
nextstate = -1;
question = "I am willing. (Pay 150 gold.)";
text1 = "She closes her eyes and begins to mumble sacred chantings.  Soon there is a flash of light, and you are restored.";
text3 = "_I guess you are all right after all._";
text5 = "_I am afraid that you don't have the money.  Please return when you do._";
code = 
	clear_strings();
	if (coins_amount() < 150)
		add_string(5);
	else	if (run_select_a_pc(1) == 0)
			add_string(3);
		else	{
			play_sound(24);
			add_string(1);
			restore_pc(get_selected_pc());
			change_coins(-150);	}
break;